import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
// import Unocss from '@unocss/vite'  // 确保从正确路径导入


// https://vitejs.dev/config/
export default defineConfig(async () => { 
  const UnoCss = await import('unocss/vite').then(i => i.default)
  return {
  plugins: [
    uni(),
    UnoCss()
  ],
  css: {
    preprocessorOptions: {
      // 如果'modern-compiler'不管用，可换成"modern"
      scss: {
        // additionalData: '@import "@/uni.scss";',
        // additionalData: '@import "@/uni.scss";',
        api: 'modern-compiler', // or "modern"
        silenceDeprecations: ['legacy-js-api','import'] // 忽略警告
      }
    }
  },
  server: {
    proxy: {
      '/api-mini': {
        //target: 'http://192.168.0.107:8000',
        target: 'http://127.0.0.1:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api-mini/, '/api-mini')
      }
    }
  }
}
});
